package view;

import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import java.awt.Button;
import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JButton;

import model.Variables;

import control.ActListener;
import control.MouseListener;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.border.SoftBevelBorder;
import javax.swing.border.BevelBorder;
import javax.swing.UIManager;

public class RightPanel extends JPanel {

	/**
	 * Create the panel.
	 * @param mainF 
	 */
	MainF mainF;
	ActListener ac;
	MouseListener mL;
	private JButton btnNewButton;
	private JButton btnHome;
	private JButton btnBack;
	private JButton btnSettings;
	private JButton btnAddNewHouse;
	private JButton btnConfigHouse;
	private JButton btnCreatePlant;
	private JButton btnFinancialInfo;
	private JButton btnStatsPanel;
	private Variables variables;
	
	public RightPanel(MainF mainF) {
		this.mainF = mainF;
		this.ac=mainF.getAc();
		this.variables = mainF.model.getVariables();
		setLayout(null);
		setPreferredSize(new Dimension(50, 690));
		setBackground(new Color(15,15,15));
		
		this.mL = mainF.getmL();

		setName("RightPanel");
		addMouseListener(mL);
		
		
		btnNewButton = new JButton();
		btnNewButton.setBackground(Color.WHITE);
		btnNewButton.setBorder(null);
		btnNewButton.setIcon(variables.getImgExpand());
		btnNewButton.setName("Expand");
		btnNewButton.setActionCommand("ExpandRight");
		btnNewButton.addActionListener(ac);
		btnNewButton.setBounds(10, 11, 30, 30);
		add(btnNewButton);
		
		btnSettings = new JButton("Settings");
		btnSettings.setOpaque(false);
		btnSettings.setBorder(null);
		btnSettings.setBackground(null);
		btnSettings.setIcon(variables.getBtnSettings());
		btnSettings.setPressedIcon(variables.getBtnSettingsPressed());
		btnSettings.setFont(variables.getFontTileHeader());
		btnSettings.setText("");
		btnSettings.setActionCommand("Settings");
		btnSettings.addActionListener(ac);
		btnSettings.setBounds(50, 50, 110, 42);
		add(btnSettings);
		
		btnAddNewHouse = new JButton("");
		btnAddNewHouse.setOpaque(false);
		btnAddNewHouse.setBackground(null);
		btnAddNewHouse.setBorder(null);
		btnAddNewHouse.setIcon(variables.getBtnAddNewHouse());
		btnAddNewHouse.setPressedIcon(variables.getBtnAddNewHousePressed());
		btnAddNewHouse.setActionCommand("NewHouse");
		btnAddNewHouse.addActionListener(ac);
		btnAddNewHouse.setBounds(50, 200, 120, 42);
		add(btnAddNewHouse);
		
		btnConfigHouse = new JButton("");
		btnConfigHouse.setOpaque(false);
		btnConfigHouse.setBackground(null);
		btnConfigHouse.setBorder(null);
		btnConfigHouse.setIcon(variables.getBtnConfigHouse());
		btnConfigHouse.setPressedIcon(variables.getBtnConfigHousePressed());
		btnConfigHouse.setActionCommand("ConfigHouse");
		btnConfigHouse.addActionListener(ac);
		btnConfigHouse.setBounds(50, 250, 110, 42);
		add(btnConfigHouse);
		
		btnCreatePlant = new JButton("");
		btnCreatePlant.setOpaque(false);
		btnCreatePlant.setBackground(null);
		btnCreatePlant.setBorder(null);
		btnCreatePlant.setIcon(variables.getBtnCreatePlant());
		btnCreatePlant.setPressedIcon(variables.getBtnCreatePlantPressed());
		btnCreatePlant.setActionCommand("NewPlant");
		btnCreatePlant.addActionListener(ac);
		btnCreatePlant.setBounds(50, 100, 110, 42);
		add(btnCreatePlant);
		
		btnFinancialInfo = new JButton("");
		btnFinancialInfo.setOpaque(false);
		btnFinancialInfo.setBackground(null);
		btnFinancialInfo.setBorder(null);
		btnFinancialInfo.setIcon(variables.getBtnFinancialInfo());
		btnFinancialInfo.setPressedIcon(variables.getBtnFinancialInfoPressed());
		btnFinancialInfo.setActionCommand("");
		btnFinancialInfo.addActionListener(ac);
		btnFinancialInfo.setBounds(50, 150, 110, 42);
		add(btnFinancialInfo);
		
		btnStatsPanel = new JButton("");
		btnStatsPanel.setOpaque(false);
		btnStatsPanel.setBackground(null);
		btnStatsPanel.setBorder(null);
		btnStatsPanel.setIcon(variables.getBtnStatistics());
		btnStatsPanel.setPressedIcon(variables.getBtnStatisticsPressed());
		btnStatsPanel.setActionCommand("StatsPanel");
		btnStatsPanel.addActionListener(ac);
		btnStatsPanel.setBounds(50, 300, 110, 42);
		add(btnStatsPanel);
		
		btnHome = new JButton();
		btnHome.setName("");
		btnHome.setBorder(null);
		btnHome.setIcon(variables.getBtnHome());
		btnHome.setPressedIcon(variables.getBtnHomePressed());
		btnHome.setBackground(Color.WHITE);
		btnHome.setActionCommand("ShowHomepage");
		btnHome.addActionListener(ac);
		btnHome.setBounds(10, 386, 25, 25);
		add(btnHome);
		
		btnBack = new JButton();
		btnBack.setName("Expand");
		btnBack.setBorder(null);
		btnBack.setIcon(variables.getBtnBack());
		btnBack.setPressedIcon(variables.getBtnBackPressed());
		btnBack.setBackground(Color.WHITE);
		btnBack.setActionCommand("Back");
		btnBack.addActionListener(ac);
		btnBack.setBounds(10, 427, 25, 25);
		add(btnBack);
		
	
	}
	public void addAll(){
		add(btnNewButton);
		add(btnSettings);
		add(btnAddNewHouse);
		add(btnConfigHouse);
		add(btnCreatePlant);
		add(btnHome);
		add(btnBack);
		add(btnFinancialInfo);
		add(btnStatsPanel);
	}
	
	public void configHouse(){
		
	}
	
	
	
	
	public void changSize(Boolean trueFalse){
		if(trueFalse){
		btnNewButton.setBounds(9, 11, 30, 30);
		btnHome.setBounds(9, 386, 30, 30);
		btnBack.setBounds(9, 427, 30, 30);
		btnSettings.setBounds(49, 46, 110, 42);
		btnAddNewHouse.setBounds(49, 206, 110, 42);
		btnConfigHouse.setBounds(49, 153, 110, 42);
		btnCreatePlant.setBounds(49, 99, 110, 42);
		btnStatsPanel.setBounds(49, 303, 110, 42);
		}else{
			btnNewButton.setBounds(10, 11, 30, 30);
			btnHome.setBounds(10, 386, 30, 30);
			btnBack.setBounds(10, 427, 30, 30);
			btnSettings.setBounds(50, 46, 110, 42);
			btnAddNewHouse.setBounds(50, 206, 110, 42);
			btnConfigHouse.setBounds(50, 153, 110, 42);
			btnCreatePlant.setBounds(50, 99, 110, 42);
			btnStatsPanel.setBounds(50, 303, 110, 42);
		}
	}
	
	public JButton getBtnSettings() {
		return btnSettings;
	}
	public void setBtnSettings(JButton btnSettings) {
		this.btnSettings = btnSettings;
	}
	public JButton getBtnAddNewHouse() {
		return btnAddNewHouse;
	}
	public void setBtnAddNewHouse(JButton btnAddNewHouse) {
		this.btnAddNewHouse = btnAddNewHouse;
	}
	public JButton getBtnAddSections() {
		return btnConfigHouse;
	}
	public void setBtnAddSections(JButton btnAddSections) {
		this.btnConfigHouse = btnAddSections;
	}
	public JButton getBtnAddPlant() {
		return btnCreatePlant;
	}
	public void setBtnAddPlant(JButton btnAddPlant) {
		this.btnCreatePlant = btnAddPlant;
	}
	public JButton getBtnNewButton() {
		return btnNewButton;
	}
	public void setBtnNewButton(JButton btnNewButton) {
		this.btnNewButton = btnNewButton;
	}
}
